//
//  WLHomeSectionHeaderView.swift
//  WalkerLove
//
//  Created by Z on 2020/4/18.
//  Copyright © 2020 Carlson. All rights reserved.
//  分组view

import UIKit

class WLHomeSectionHeaderView: UITableViewHeaderFooterView {
    
    enum WLSHType {
        case health, activity
    }
    
    var stype: WLSHType?
    var hImgView: UIImageView?
    var hLab: UILabel?
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }

    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        initSubviews()
    }
    
    func initSubviews() {
        self.backgroundColor = .clear
        backgroundView = UIView()
        contentView.backgroundColor = .clear
        
        hImgView = UIImageView()
        hLab = UILabel()
        hLab?.textColor = DeviceTool.ColorFromRGB(0x222222)
        hLab?.font = UIFont(name: "PingFangSC-Medium", size: 16)
        hLab?.textAlignment = NSTextAlignment.left
        
        contentView.addSubview(hImgView!)
        contentView.addSubview(hLab!)
        
        hImgView?.snp.makeConstraints({
            $0.left.equalToSuperview().offset(15)
            $0.centerY.equalToSuperview().offset(0)
            $0.size.equalTo(CGSize(width: 14, height: 14))
        })
        hLab?.snp.makeConstraints({
            $0.left.equalTo(hImgView!.snp_right).offset(4)
            $0.centerY.equalTo(hImgView!)
        })
    }
    
    func headerSeationType(type: Int) {
        switch type {
        case 0:
            hImgView?.image = UIImage(named: "home_helth_data_icon")
            hLab?.text = "健康数据"
        case 1:
            hImgView?.image = UIImage(named: "home_hot_action_icon")
            hLab?.text = "最热活动"
        default:
            break
        }
    }
}
